import {
  axios
} from '@/utils/request'
// 批量获取文件详情
function getFileInfo (ids) {
  return axios({
    url: '/file-service/file/info',
    method: 'get',
    params: {
      ids: ids
    },
  })
}
// 分块初始化
function chunkInit (data) {
  return axios({
    url: '/file-service/file/chunk/init',
    method: 'post',
    data,
    timeout: 600000
  })
}
// 分块上传
function chunkUpload (data) {
  return axios({
    url: '/file-service/file/chunk',
    method: 'post',
    data,
    timeout: 600000
  })
}
// 合并
function fileMerge (item) {
  return axios({
    url: '/file-service/file/merge',
    method: 'post',
    data: item
  })
}

// 软件管控-分块上传
function chunkPartUpload (data) {
  return axios({
    url: '/file-service/file/part/chunk',
    method: 'post',
    data,
    timeout: 600000
  })
}
// 软件管控-合并
function filePartMerge (item) {
  return axios({
    url: '/file-service/file/part/merge',
    method: 'post',
    data: item
  })
}
// 整体上传文件到本地
function uploadWholeFileToLocal (data, params) {
  return axios({
    url: '/file-service/file',
    method: 'post',
    data,
    params
  })
}
// 上传小文件到华为云
function uploadLittleFileToCloud (data, params) {
  return axios({
    url: '/file-service/file/addSwFile',
    method: 'post',
    data,
    params
  })
}
// 下载文件到本地
function downloadFileToLocal (params) {
  return axios({
    url: '/file-service/file/download',
    method: 'post',
    params,
    responseType: 'blob'
  })
}

// 下载文件到本地
function downloadErrorLog (params) {
  return axios({
    url: '/file-service/file/downloadErrorLog',
    method: 'post',
    params,
    responseType: 'blob'
  })
}

// 异常日志打包下载日志
function downloadZip (params) {
  return axios({
    url: '/file-service/file/downloadZip',
    method: 'post',
    params,
    responseType: 'blob',
    timeout: 600000
  })
}

export default {
  getFileInfo,
  chunkInit,
  chunkUpload,
  fileMerge,
  filePartMerge,
  chunkPartUpload,
  uploadWholeFileToLocal,
  uploadLittleFileToCloud,
  downloadFileToLocal,
  downloadErrorLog,
  downloadZip
}
